<?php
/**
 * Created by PhpStorm.
 * User: yangfan
 * Date: 2019/11/20
 * Time: 3:00 PM
 */

namespace App\BO\Product;

use App\Entities\UserAddressEntity;
use App\Services\LocationService;

class ProductSkuServiceAreaBO
{
    /**
     * @var int
     */
    private $cityId;

    /**
     * @var int
     */
    private $provinceId;

    /**
     * @var int
     */
    private $productId;

    /**
     * @param UserAddressEntity $addressEntity
     * @param int $productId
     */
    public function __construct(UserAddressEntity $addressEntity, int $productId)
    {
        $this->cityId = $addressEntity->getCityId();
        $this->provinceId = $addressEntity->getProvinceId();
        $this->productId = $productId;
    }

    /**
     * @return bool
     */
    public function hasService()
    {
        if (LocationService::hasServiceInArea($this->productId, $this->cityId)) {
            return true;
        }
        return false;
    }
}
